<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:replace="components/head :: head(~{:: title}, ~{:: link})">
    <meta charset="UTF-8">
    <title>用户管理</title>
    <link rel="stylesheet" href="/css/wen.css">
</head>
<body>
<!-- Header -->
<header th:replace="_fragments/nav :: navbar"></header>
<!-- End Header -->


<!-- Content -->
<div class="container">
    <div class="alert alert-danger" role="alert"
         th:if="${errInfo != null}" th:text="${errInfo}"></div>
    <div class="alert alert-success" role="alert"
         th:if="${successInfo != null}" th:text="${successInfo}"></div>

    <!-- Body -->
    <div th:if="${user != null}">
        <h1>修改用户信息</h1>
        <form th:action="@{'/admin/user/edit/' + ${user.getId()}}" method="post">
            <div class="form-group">
                <label for="new_user_name">用户名</label>
                <input id="new_user_name" type="text" class="form-control" name="username"
                       placeholder="标签名称" th:value="${user.getUsername()}">
            </div>
            <div class="form-group">
                <label for="new_nickname">用户昵称</label>
                <input id="new_nickname" type="text" class="form-control" name="nickname"
                       placeholder="用户昵称" th:value="${user.getNickname()}">
            </div>
            <div class="form-group">
                <label for="new_email">电子邮箱</label>
                <input id="new_email" type="text" class="form-control" name="email"
                       placeholder="电子邮箱" th:value="${user.getEmail()}">
            </div>
            <input type="submit" value="Submit" class="btn btn-default">
        </form>
    </div>

    <div class="container" th:if="${user == null}">
        <h1 style="margin: 40px 0 40px 0;">User Manage</h1>
        <table class="table table-striped">
            <thead>
            <tr>
                <td>序号</td>
                <td>id</td>
                <td>用户名</td>
                <td>昵称</td>
                <td>注册时间</td>
                <td>角色</td>
                <td>操作</td>
            </tr>
            </thead>
            <tbody>
            <tr th:each="user, iterStat : ${page.content}">
                <td th:text="${iterStat.count}"></td>
                <td th:text="${user.id}"></td>
                <td th:text="${user.username}"></td>
                <td th:text="${user.nickname}"></td>
                <td th:text="${user.createTime}"></td>
                <td th:text="${user.role}"></td>
                <td>
                    <a th:href="@{'/admin/user/edit/' + ${user.id}}" class="btn btn-default">修改</a>
                    <a th:href="@{'/admin/user/delete/' + ${user.id}}" class="btn btn-default">删除</a>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <!-- End Body -->


    <!-- Footer -->
    <div th:replace="components/footer :: footer"></div>
    <!-- End Footer -->
</div>
<!-- End Content -->
</body>
</html>
